package org.example.filter;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
import java.io.IOException;

/**
 * @author Administrator
 */
@WebFilter(
    urlPatterns = "/*",
    initParams = {@WebInitParam(name = "encoding", value = "UTF-8")}
)
@Slf4j
public class MyFilter implements Filter {
    @Override
    public void init(FilterConfig config) {
        // 初始化逻辑
        log.info("MyFilter init...");
    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws ServletException, IOException {
        log.info("do filter...");
        // 过滤逻辑
        chain.doFilter(req, res);
    }
}